// pages/home/home.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 轮播图数组
    swiperList: [{
        "image_src": "https://api-hmugo-web.itheima.net/pyg/banner1.png",
        "open_type": "navigate",
        "goods_id": 129,
        "navigator_url": "/pages/goods_detail/index?goods_id=129"
      },
      {
        "image_src": "https://api-hmugo-web.itheima.net/pyg/banner1.png",
        "open_type": "navigate",
        "goods_id": 129,
        "navigator_url": "/pages/goods_detail/index?goods_id=129"
      }
    ],
    // 导航 数组
    catesList: [{
        "name": "分类",
        "image_src": "../../icons/fenlei.png",
        "open_type": "switchTab",
        "navigator_url": "pages/category/category"
      },
      {
        "name": "秒杀拍",
        "image_src": "../../icons/miaosha.png"
      },
      {
        "name": "超市购",
        "image_src": "../../icons/chaoshigou.png"
      },
      {
        "name": "教育",
        "image_src": "../../icons/jiaoyu.png"
      },
      {
        "name": "客服",
        "image_src": "../../icons/kefu.png"
      }
    ],
    goodsList: [{
      "_id": "15",
      "name": "新鲜大橙子",
      "price": "9.9",
      "count": "50",
      "categoryId": "7769e02464c08db300a7e70b4363841d",
      "imageUrl": "http://tse2-mm.cn.bing.net/th/id/OIP-C.5FIqSPvF-49fJLfdc0XizwHaFq?w=216&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "16",
      "name": "淘宝新款衣服",
      "price": "89.9",
      "count": "120",
      "categoryId": "f0a517a864c08dcf0001834c47dce4ae",
      "imageUrl": "http://tse1-mm.cn.bing.net/th/id/OIP-C.b5fzJ4MlxyIvnHDKcCLt9gHaE7?w=247&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "17",
      "name": "新鲜猪肉",
      "price": "19.5",
      "count": "100",
      "categoryId": "f0a517a864c08e2e000189981b961d63",
      "imageUrl": "http://tse1-mm.cn.bing.net/th/id/OIP-C.BfE4My1miXY4R2eNvqDA6wHaEW?w=281&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "1",
      "name": "新鲜大橙子",
      "price": "9.9",
      "count": "50",
      "categoryId": "7769e02464c08db300a7e70b4363841d",
      "imageUrl": "http://tse4-mm.cn.bing.net/th/id/OIP-C.qbMXXw68RfD85tzqOKPoXQHaE8?w=247&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "2",
      "name": "淘宝新款衣服",
      "price": "89.9",
      "count": "120",
      "categoryId": "f0a517a864c08dcf0001834c47dce4ae",
      "imageUrl": "http://tse3-mm.cn.bing.net/th/id/OIP-C.djZa-q8_f869A7F3D8VnIgHaE8?w=276&h=184&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "3",
      "name": "新鲜猪肉",
      "price": "19.5",
      "count": "100",
      "categoryId": "f0a517a864c08e2e000189981b961d63",
      "imageUrl": "http://tse4-mm.cn.bing.net/th/id/OIP-C.YQ66YuzEBgHN8eKGbMDX-QHaE7?w=280&h=186&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "4",
      "name": "新鲜大橙子",
      "price": "9.9",
      "count": "50",
      "categoryId": "7769e02464c08db300a7e70b4363841d",
      "imageUrl": "http://tse3-mm.cn.bing.net/th/id/OIP-C.ecStc34IE-bhTSfc7-NCjAHaEr?w=309&h=195&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "5",
      "name": "淘宝新款衣服",
      "price": "89.9",
      "count": "120",
      "categoryId": "f0a517a864c08dcf0001834c47dce4ae",
      "imageUrl": "http://tse1-mm.cn.bing.net/th/id/OIP-C.XoarlAWLdiYvBpqwsN4K1wHaHa?w=194&h=195&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }, {
      "_id": "5",
      "name": "淘宝新款衣服",
      "price": "89.9",
      "count": "120",
      "categoryId": "f0a517a864c08dcf0001834c47dce4ae",
      "imageUrl": "http://tse1-mm.cn.bing.net/th/id/OIP-C.XoarlAWLdiYvBpqwsN4K1wHaHa?w=194&h=195&c=7&r=0&o=5&dpr=1.3&pid=1.7"
    }]
  },

  /**
   * 跳转到分类
   */
  gotocategory(){
    wx.switchTab({
      url: '../category/category',
    })
  },

  /**
   * 商品详情页
   */
  showDetail(e){
    const pid = e.currentTarget.dataset.pid;
    console.log(pid);
    wx.navigateTo({
      url: '../productDetail/index?pid='+pid,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})